#!/bin/bash
echo "检查是否安装docker,docker-compose环境"
docker -v
if [ $? -eq  0 ]; then
 echo "检查到Docker已安装!"
else
 echo "安装docker环境..."
 curl https://gitee.com/ligson/centos7script/raw/master/crux-tools/cruxInstall.sh | bash -s init
fi
if [ -d "/data/docker/service/redis/" ];then
  echo "/data/docker/service/redis 文件夹已经存在,请手动确认后删除该目录,再执行创建"
  exit
fi
if [ ! -d "/data/docker/service/" ];then
  mkdir -p /data/docker/service
fi
echo "redis的密码默认是crux,如果需要修改密码,请修改conf/redis.conf配置文件中的requirpass 属性的值,然后重启redis服务即可"
cd /data/docker/service
wget https://zwfile.yonyougov.top/share/crux-tools/redis-pass/redis-pass.tar.gz --no-check-certificate
tar -zxvf redis-pass.tar.gz
rm -rf redis-pass.tar.gz
wget https://zwfile.yonyougov.top/share/crux-tools/redis-pass/crux-redis-image.tar.gz --no-check-certificate
docker load -i crux-redis-image.tar.gz
rm -rf crux-redis-image.tar.gz
cd redis
docker network ls | grep mynetwork
if [ $? -eq  0 ]; then
 echo "Docker网络mynetwork已存在!"
else
 echo "创建docker网络"
 docker network create mynetwork
fi
echo "启动redis"
docker-compose up -d
